<template>
  <view class="goodsItem" @click="goPage('/pages/shopCar/goodsDetails')">
    <view class="imgBox">
      <image :src="goodsInfo?.image" mode=""></image>
    </view>
    <view class="textBox">
      <slot name="type"></slot>
      <view class="name">{{ goodsInfo?.name }}</view>
      <view class="priceBox">
        <view class="price">
          <text class="priceUnit">￥</text>
          {{ goodsInfo?.price || 23 }}
          <text class="unit">/盒</text>
        </view>
        <view class="right">+</view>
      </view>
    </view>
  </view>
</template>

<script lang="ts" setup>
import { goPage } from "../utils/commonFn";
const { goodsInfo } = defineProps<{
  goodsInfo: any;
}>();
</script>

<style lang="less" scoped>
.goodsItem {
  width: 100%;
  .imgBox {
    width: 100%;
    height: 343rpx;
    display: flex;
    justify-content: center;
    align-items: center;
    background: #ebecf1;
    image {
      width: 100%;
      height: 100%;
      background-color: #ebecf1;
      border-radius: 16rpx 16rpx 8rpx 8rpx;
    }
  }
  .textBox {
    background: #fff;
    padding: 20rpx;

    .name {
      font-size: 30rpx;
      font-weight: bold;
      color: #333333;
      line-height: 44rpx;
      overflow: hidden;
      text-overflow: ellipsis; //文本溢出显示省略号
      white-space: nowrap; //文本不会换行
    }
    .priceBox {
      display: flex;
      justify-content: space-between;
      align-items: center;
      margin-top: 22rpx;
      .price {
        font-size: 32rpx;
        font-weight: bold;
        color: #f94a15;
        .priceUnit {
          font-size: 24rpx;
          margin-right: -12rpx;
        }
        .unit {
          font-weight: 500;
          color: #bebebe;
          line-height: 34rpx;
          font-size: 28rpx;
        }
      }
      .right {
        width: 48rpx;
        height: 48rpx;
        background: linear-gradient(90deg, #69e07d 0%, #2ed19a 33%, #1bbd7e 100%);
        border-radius: 56rpx;
        text-align: center;
        line-height: 44rpx;
        color: #fff;
        font-size: 40rpx;
      }
    }
  }
}
</style>
